#!/usr/bin/env python
# coding=utf-8

import os
import sys
import re
import optparse
import winsound

from os.path import join as pjoin

buildlog = open('build.log', 'w')

class ModelSrc:
	""" manage the source of a model, mainly include download, update, build and delete.\n"""

	# all the models
	models = ('je609', 'nx005', 'nx007', 'jg500')
	# nicknames of the models, they are used at some time(some folder name)
	nickName = {'je609': '09DOP',
			'nx005': '09OverseaSL',
			'nx007': '09OverseaH',
			'jg500': '09CH'}
	# build target for Build or Rebuild
	targets = ('Rebuild', 'Build')
	# build configuration of Release and Debug
	configs = ('Release', 'Debug')
	# all used SDK
	platforms = ('Windows Mobile 5.0 Pocket PC SDK (ARMV4I)', 
				'09Light Platform (ARMV4I)',
				'WS_NX005 (ARMV4I)')
	# special platform for model
	modelPlatform =  {'je609': platforms[1],
			'nx005': platforms[2],
			'nx007': platforms[1],
			'jg500': platforms[1]}

	def __init__(self, model, **args):
		""" variable args: basepath\n """
		self.model = model
		if args.has_key('basepath'):
			self.basepath = os.path.abspath(args.basepath)
		else:
			self.basepath = os.path.abspath('.')
		self.modelDir = model + 'Apl'
		self.logf = sys.stdout
	
	def setLogFile(f):
		""" parameter is a filename or a opened writable file\n"""
		if isinstance(f,file):
			self.logf = f
		else:
			self.logf = open(f,'a')

	def download():
		""" download the source\n """
		pass

	def update():
		""" update the souce\n """
		pass

	def delete():
		""" delete the whole folder for the model source\n"""
		pass

